package com.ldatum.crm.daoImpl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.ldatum.crm.dao.LogsServiceDao;
import com.ldatum.crm.domain.TLogs;
import com.ldatum.crm.util.HibernateUtil;

public class LogsServiceDaoImpl implements LogsServiceDao {

	@Override
	public List<TLogs> list() throws Exception {
		Session s = null;
		try {
			s = HibernateUtil.getSession();
			String hql = "from TLogs as logs";
			Query q = s.createQuery(hql);
			@SuppressWarnings("unchecked")
			List<TLogs> list = (List<TLogs>) q.list();
			return list;
		}finally{
			if(s!=null){
				s.close();
			}

		}
	}

	@Override
	public void save(TLogs logs) throws Exception {
		HibernateUtil.add(logs);
	}

}
